import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class NGuessNumberTest {
    class generateAnswerTest {
        @Test
        void generateAnswer() {

            {
                int s = 4;
                NGuessNumber nGuessNumber = new NGuessNumber();
                assertEquals(s, nGuessNumber.generateAnswer().length);
                System.out.println("数字为4个，正确");
                int num[] = nGuessNumber.generateAnswer();

                boolean flag = false;
                int numsize = 0;

                for (int i = 0; i < s; i++) {
                    if (num[i] >= 0 && num[i] <= 9) {
                        numsize = 1;
                    } else {
                        numsize = 0;
                    }
                    for (int l = 0; l <= i; l++) {
                        if (i != l) {
                            if (num[i] == num[l]) {
                                flag = false;
                            } else {
                                flag = true;
                            }
                        }
                    }
                }

                assertEquals(true, flag);
                System.out.println("其中无重复数字，正确");
                assertEquals(1, numsize);
                System.out.println("数字都在0-9之间，正确");

            }
        }
    }

    class getPlayerInputTest{
        @Test
        void getPlayerInput() {
            //请使用断言检查玩家猜测的数字数量是否为4。
            int numsize = 4;

            NGuessNumber nGuessNumber = new NGuessNumber();

            assertEquals(numsize,nGuessNumber.guesslist.length);

            System.out.println("用户输入的数字数量为4，正确");
        }
    }

}